<template>
    <div class="lyear-layout-web">
        <div class="lyear-layout-container">
            <the-aside></the-aside>

            <the-header title="入仓订单列表"></the-header>


            <the-button :msg="msg" :fun="fun"></the-button>


            <!--页面主要内容-->
            <main class="lyear-layout-content">

                <div class="container-fluid">

                    <div class="row">
                        <div class="col-lg-12">
                            <div class="card">
                                <div class="card-toolbar clearfix">
                                    <form class="pull-right search-bar" style="max-width:460px;" role="form">
                                        <div class="input-group">
                                            <div class="input-group-btn">
                                                <input type="hidden" name="search_field" id="search-field" value="title">
                                                <button class="btn btn-default dropdown-toggle" id="search-btn" data-toggle="dropdown" type="button" aria-haspopup="true" aria-expanded="false">
                                                    订单编号 <span class="caret"></span>
                                                </button>
                                                <ul class="dropdown-menu">
                                                    <li> <a tabindex="-1" href="javascript:void(0)"  data-field="title">订单编号</a> </li>
                                                </ul>
                                            </div>
                                            <input id="search-name" style="width:280px"  type="text " v-model="searchContent" class="form-control" value="" placeholder="请输入要搜索的内容..">
                                            <a class="btn btn-pink" href="javascript:void(0);" @click="searchIncomingOrder"><i class="mdi mdi-search-web"></i> 搜索</a>
                                        </div>
                                    </form>
                                    <div class="toolbar-btn-action">
                                        <a class="btn btn-info m-r-5" href="javascript:void(0);" @click="refresh"><i class="mdi mdi-rotate-3d"></i> 刷新</a>
                                    </div>
                                </div>
                                <div class="card-body">

                                    <div class="table-responsive">
                                        <table class="table table-bordered">
                                            <thead>
                                            <tr>
                                                <th style="width:25%">编号</th>
                                                <th style="width:25%">采购订单编号</th>
                                                <th style="width:25%">卖方公司名称</th>
                                                <th style="width:25%">入仓日期</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr v-for="incomingOrder in incomingOrderList" >
                                                <td :id="'incomingOrder-id-'+incomingOrder.id" v-text="incomingOrder.id"></td>
                                                <td :id="'incomingOrder-purchase-order-id-'+incomingOrder.id" v-text="incomingOrder.purchaseId"></td>
                                                <td :id="'incomingOrder-sell-company-'+incomingOrder.id" v-text="incomingOrder.sellerName"></td>
                                                <td :id="'incomingOrder-incoming-date-'+incomingOrder.id" v-text="incomingOrder.incomingDate"></td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>

                                    <!-- 分页 -->
                                    <the-pagination :page="page" :getData="getData" :searchContent="searchContent" :searchType="searchType" :totalPage="totalPage"></the-pagination>


                                </div>
                            </div>
                        </div>

                    </div>

                </div>

            </main>
            <!--End 页面主要内容-->
        </div>
    </div>
</template>



<script>
    import TheHeader from "../components/the-header";
    import TheAside from "../components/the-aside";
    import TheButton from "../components/the-button";
    import ThePagination from "../components/the-pagination";
    export default {
        name: 'incoming-order-list',
        components: {TheHeader, TheAside, TheButton, ThePagination},
        data: function() {
            return {
                incomingOrder: {},
                incomingOrderDetailDtoList:[],
                incomingOrderList: [],
                msg: "",
                fun:"",
                page: 1,
                totalPage: 1,
                searchContent: '',
                searchType: 'id'
            }
        },
        //mounted 页面渲染完后执行 钩子函数
        mounted:function(){
            $('.search-bar .dropdown-menu a').click(function() {
                let field = $(this).data('field') || '';
                $('#search-field').val(field);
                $('#search-btn').html($(this).text() + ' <span class="caret"></span>');
            });
            //获取种类列表的数据
            let _this = this;
            let data = {
                page: _this.page,
                searchContent: _this.searchContent,
                searchType: _this.searchType
            };
            _this.getData(data);
        },
        created:function() {

        },
        methods:{
            getData(data){
                Loading.show();
                let _this = this;
                _this.$ajax.post(process.env.VUE_APP_SERVER + "/incoming_order/get_data", data).then((response)=>{
                    let resp = response.data;
                    Loading.hide();
                    if(resp.code === 0){
                        _this.incomingOrderList = resp.data.list;
                        _this.page = resp.data.page;
                        _this.totalPage = resp.data.totalPage;
                    }else{
                        _this.msg = resp.msg;
                        $("#alert-button").click();
                    }
                });
            },
            refresh(){
                window.location.reload();
            },
            searchIncomingOrder(){
                let _this = this;
                //获取种类列表的数据
                let data = {
                    page: _this.page,
                    searchContent: _this.searchContent,
                    searchType: _this.searchType
                };
                _this.getData(data);
            },
            permissionCheck(url){
                let permissionList = Permission.getPermission();
                for(let i=0; i<permissionList.length; i++){
                    if(url === permissionList[i]){
                        return true;
                    }
                }
                return false;
            }
        }
    }

</script>


<style>
</style>


